package com.dzsw.struts.action;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.concurrent.atomic.AtomicInteger;

public class MyAction extends Action {

    private AtomicInteger index = new AtomicInteger(0);

    public MyAction() {
        super();
        System.out.println(Thread.currentThread().getId() + " ---- Create MyAction.");
    }

    @Override
    public ActionForward execute(ActionMapping mapping,
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response) throws Exception {
        MyForm myForm = (MyForm) form;
        myForm.setRadioArea("5");
        myForm.setCheckbox1("");
        myForm.setCheckbox2("on");
        myForm.setMultiBox(new String[] {"4", "5", "7"});
        System.out.println(Thread.currentThread().getId() + " ------ " + index.getAndAdd(1));
        return mapping.findForward("success");
    }
}
